interface KHTMLElement {
    /**
     * 设置值
     * @param value 值
     * @param readonly true: 允许设置 readonly 状态的值; false: 不允许设置 readonly 状态的值;
     * @param disabled true: 允许设置 disabled 状态的值; false: 不允许设置 disabled 状态的值;
     * @returns 当前元素对象
     */
    setValue(value: any, readonly?: boolean, disabled?: boolean): KHTMLElement;
}
{
    Object.defineProperty(KHTMLElement.prototype, 'setValue', {
        writable: false,
        configurable: false,
        enumerable: false,
        value: function (this: KHTMLElement, value: any, readonly = true, disabled = false): KHTMLElement {
            const plugin = this.getPlugin(__CVP__);
            if (!plugin) {
                // 不是值控件，也不在值控件内，报错。
                throw new IllegalArgumentError(`${U.stringValue(this, 'title')} is not a value plugin.`);
            }
            if (readonly === false && plugin.hasClass(_CP_.CLASSES.READONLY)) { return this; }
            if (disabled === false && plugin.hasClass(_CP_.CLASSES.DISABLED)) { return this; }
            (plugin.ele()!.creator as __CVP__<any>).setValue(value);
            return this;
        }
    });
}
